package com.itheima.duotai3;

public class Demo01 {
    public static void main(String[] args) {
        Animal animal = getAnimal();
        animal.eat();
    }

    //想要一个方法生产一个动物
    public static Dog getDog(){
        return new Dog();
    }
    public static Cat getCat(){
        return new Cat();
    }
    public static Pig getPig(){
        return new Pig();
    }
    public static Animal getAnimal(){
        return new Dog();
      //  return  new Cat();
       // return new Pig();
    }
}
abstract class Animal{
    public abstract  void eat();
}
class Dog extends Animal{

    @Override
    public void eat() {
        System.out.println("狗吃肉");
    }
}
class Cat extends Animal{

    @Override
    public void eat() {
        System.out.println("猫吃鱼");
    }
}
class Pig extends Animal{

    @Override
    public void eat() {
        System.out.println("猪吃饲料");
    }
}